import { defineStore } from 'pinia';
import { deviceDetection } from '/@/utils/deviceDetection/index';
interface State {
    // 是否收缩侧边栏
    collapsed: boolean;
    // 是否固定顶部导航栏
    fixedNav: boolean;
    // 顶部导航栏高度
    navHeight: number;
    // 页面宽度
    appWidth: number;
    // 是否移动设备
    isMobile: boolean
}
export const useAppStore = defineStore('app', {
    state: (): State => ({
        collapsed: false,
        fixedNav: true,
        navHeight: 50,
        appWidth: 1920,
        isMobile: deviceDetection()
    }),
    getters: {

    },
    actions: {
        SET_COLLAPSED(val: boolean) {
            this.collapsed = val
        },
        SET_FIXE_NAV(val: boolean) {
            this.fixedNav = val
        },
        SET_APP_WIDTH(val: number) {
            this.appWidth = val
        },
        SET_IS_MOBILE(val: boolean) {
            // 桌面时才能更改
            if (!deviceDetection()) {
                this.isMobile = val
            }
        }
    }
})